<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace app\home\controller;

use app\home\model\MemberModel;
use app\home\model\RechargeModel;
use cmf\controller\UserBaseController;
use think\Db;


class PassworkController extends UserBaseController
{
    public function index(){
        $uinfo= cmf_get_current_user(); 
        //dump($uinfo);
        //当天收银方式汇总
        $today_time=strtotime('today');
        $yesterday_time=strtotime('yesterday');
        $where['operatorid']=$uinfo['id'];
        $where['storeid']=$uinfo['store_id'];
        $where['payStatus']=1;
        $where['ctime'][]=array('gt',$yesterday_time);
        $where['ctime'][]=array('lt',$today_time);
        $order=DB::name('Order')->where($where)->select();
        $total_money=Db::name('Order')->where($where)->sum('totalMoney');//该店铺该商品总营业额
        $actualMoney=Db::name('Order')->where($where)->sum('actualMoney');//该店铺该商品总营业额
        $count=Db::name('Order')->where($where)->count();//该店铺该商品总营业额
        //dump($total_money);
        $this->assign('total_money',$total_money);
        $this->assign('actualMoney',$actualMoney);
        $this->assign('count',$count);
        $this->assign('order',$order);
        $this->assign('uinfo',$uinfo);   
        return $this->fetch();
    }            
        
    function consume(){
        //交班消费统计
       $j=DB::name('order_detail')
            ->alias('d')
            ->join('goods g','d.goodsid=g.g_id','left')
           ->join('goods_classify c','g.g_category=c.id')
            ->select();
        //$j=DB::name('goods')->where('g_goodsname',$j['g_goodsname'])->column('id');
        //$c=$j[0]['g_category'];
        foreach($j as $k=>$v){
          $cate=DB::name('goods_classify')->where('id',$v['g_category'])->select();
            //var_dump($c);
            $this->assign('cate',$cate);
            //$this->display();
        }
        return $this->fetch();
    }
    function retire(){
        //退餐情况统计
        return $this->fetch();
    }
    function back(){
        //取消
        return $this->fetch('member/index');
    }
    function passwork(){
       session("user", null);//只有前台用户退出
       return redirect($this->request->root() . "/");
    }   
    function cancel(){
        session("user", null);//只有前台用户退出  
        $redirect='/user/login/index';
        $this->success('注销成功', $redirect);
        //return redirect();
    }
}
























